package com.aaa.controller.fpa;

import com.aaa.entity.LayData;
import com.aaa.entity.MyPage;
import com.aaa.entity.User;
import com.aaa.entity.fpa.TFpaPlane;
import com.aaa.service.fpa.TFpaPlaneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Date;


@RestController
@RequestMapping("tFpaPlane")
public class TFpaPlaneController {
    /**
     * 服务对象
     */
    @Autowired
    private TFpaPlaneService tFpaPlaneService;


    // 查询所有的执行计划
    @GetMapping
    public LayData queryAll(MyPage myPage){
       return new LayData(tFpaPlaneService.queryAll(myPage));
    }

    @PostMapping
    public LayData checkCode(TFpaPlane plane){
        return new LayData(tFpaPlaneService.selectPlane(plane));
    }
    @PostMapping("addPlane")
    public LayData addPlane(TFpaPlane plane, HttpSession session){
        User user1=(User) session.getAttribute("user");
        plane.setCreatetime(new Date());
        plane.setUid(user1.getId());
        System.out.println(plane);
        return new LayData(tFpaPlaneService.insertPlane(plane));
    }

    @GetMapping("getByCode")
    public LayData queryByQyCode(TFpaPlane tFpaPlane){
        return new LayData(tFpaPlaneService.queryByQyCode(tFpaPlane));
    }

}

